import request from '@/assets/js/request';
import util from '@/assets/js/public';
import { getToken } from '@/assets/js/auth';


//获取用户信息
export function getUserdata(params){
    console.log('获取用户信息时的名字是：'+params.userName);
    return request(
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/getCurrentUser$sso',
            contentType: 'application/json;charset=UTF-8',
            data:{
                'access_token':getToken(),
                'appCode':'zbjqxxzd',
                'noAction': '1',
                'versionName':'2.7.92',
                    'kv':{
                        'versionName':'2.7.92',
                        'versionCode':2079200,
                        'appcode':'zbjqxxzd',
                        'currentUserCode':util.encrypt(params.userName),
                    }
            }
        }
    )
}

export function getTodoList(params){
    return request (
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+
            'queryActBusinessStatus$api$myTaskToDo',
            contentType: 'application/json;charset=UTF-8',
            data:{
                'access_token':getToken(),
                'appCode':'zbjqxxzd',
                'currentUserCode':util.encrypt(params.userName),
                'versionName':'2.7.92',
                'kv':{
                    'source':'MOBILE',
                    'page':params.page,
                    'rows':params.rows,
                    'size':params.size,
                    'title':params.searchTitle,
                    'currentUserCode':util.encrypt(params.userName),
                },
            }
        }
    )
}
export function getDidList(params){
    return request (
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+
            'queryActBusinessStatus$api$queryMyJoin',
            contentType: 'application/json;charset=UTF-8',
            data:{
                'access_token':getToken(),
                'appCode':'zbjqxxzd',
                'currentUserCode':util.encrypt(params.userName),
                'versionName':'2.7.92',
                'kv':{
                    'source':'MOBILE',
                    'page':params.page,
                    'rows':params.rows,
                    'size':params.size,
                    'title':params.searchTitle,
                    'currentUserCode':util.encrypt(params.userName),
                },
            }
        }
    )
}

export function getDrawList(params){
    return request (
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+
            'queryActBusinessStatus$api$myDraftToDo',
            contentType: 'application/json;charset=UTF-8',
            data:{
                'access_token':getToken(),
                'appCode':'zbjqxxzd',
                'currentUserCode':util.encrypt(params.userName),
                'versionName':'2.7.92',
                'kv':{
                    'source':'MOBILE',
                    'page':params.page,
                    'rows':params.rows,
                    'size':params.size,
                    'title':params.searchTitle,
                    'currentUserCode':util.encrypt(params.userName),
                },
            }
        }
    )
}

export function getxxzdTZList(params){
    return request (
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+
            'UsStudyMain$api$selectAll',
            contentType: 'application/json;charset=UTF-8',
            data:{
                'access_token':getToken(),
                'appCode':'zbjqxxzd',
                'currentUserCode':util.encrypt(params.userName),
                'versionName':'2.7.92',
                'kv':{
                    'source':'MOBILE',
                    'page':params.page,
                    'rows':params.rows,
                    'size':params.size,
                    'name':params.title,
                    'startDate':params.startTime,
                    'endDate':params.endTime,
                    'currentUserCode':util.encrypt(params.userName),
                },
            }
        }
    )
}
export function getxxzdDetail(params){
    return request (
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+
            'UsStudyMain$api$getFormDetail',
            contentType: 'application/json;charset=UTF-8',
            data:{
                'access_token':getToken(),
                'appCode':'zbjqxxzd',
                'currentUserCode':util.encrypt(params.userName),
                'versionName':'2.7.92',
                'kv':{
                    'source':'MOBILE',
                    'pmInsId':params.pmInsId,
                    'processInstId':params.processInstId,
                    'workFlag':params.workFlag,
                    'currentUserCode':util.encrypt(params.userName),
                },
            }
        }
    )
}
export function getxxzdOpinionDetail(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+
        'queryOpinionHistory$api$getWfOptMags?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            'access_token':getToken(),
            'appCode':'zbjqxxzd',
            'currentUserCode':util.encrypt(params.userName),
            'versionName':'2.7.92',
                'kv':{
                    'source':'MOBILE',
                    'currentUserCode':util.encrypt(params.userName),
                    'processInstId':params.processInstId,
                }
        }
    })
}

export function xxzduploadProcessFiles(fd,params){
    console.log('CCCCCCCCCC'+process.env.VUE_APP_UPFILE)
    return request({
        url:process.env.VUE_APP_URL+'/action/openapi/bps/common/uploadFile?pmInsType=A&pmInsTypePart=1&appcode=zbjqxxzd&currentUserCode='
        +util.encrypt(params.userName)+'&access_token='+getToken(),
        contentType:'multipart/form-data',
        data:fd,
        catch:true
    })
}

export function xxzdgetDecisions(params){
    console.log('name:'+params.userName)
    var usrls='UsStudyMain$api$getDecisions';
    return request(
        {
            url:process.env.VUE_APP_URL +'/action/openapi/bps/common/transmit/'+ usrls+'?source=MOBILE',
            contentType:'application/json;charset=UTF-8',
            data:{
                'access_token':getToken(),
                'appCode':'zbjqxxzd',
                'currentUserCode':util.encrypt(params.userName),
                'versionName':'2.7.92',
                'source':'MOBILE',
                'kv':{
                    'currentUserCode':util.encrypt(params.userName),
                    'source':'MOBILE',
                    'location':params.idcode.location,
                    'processInstId':params.idcode.processInstId,
                    'processDefName':params.idcode.processDefName,
                }
            }
        }
    )
}

export function xxzdgetNextUser(params){
    console.log('name:'+params.userName)
    var usrls='UsStudyMain$api$getOrgAndUser';
    return request(
        {
            url:process.env.VUE_APP_URL +'/action/openapi/bps/common/transmit/'+ usrls+'?source=MOBILE',
            contentType:'application/json;charset=UTF-8',
            data:{
                'access_token':getToken(),
                'appCode':'zbjqxxzd',
                'currentUserCode':util.encrypt(params.userName),
                'versionName':'2.7.92',
                'source':'MOBILE',
                'kv':{
                    'currentUserCode':util.encrypt(params.userName),
                    'source':'MOBILE',
                    'location':params.idcode.location,
                    'processInstId':params.idcode.processInstId,
                },
                'jsonName':'appDecision',
                'appDecision':params.decisiondata
            }
        }
    )
}
export function xxzdGotoSubmitProcess(params){
    console.log('name:'+params.userName)
    var usrls='UsStudyMain$api$startSubmitProcess';
    return request(
        {
            url:process.env.VUE_APP_URL +'/action/openapi/bps/common/transmit/'+ usrls+'?source=MOBILE',
            contentType: 'application/json;charset=UTF-8',
            data:{
                'access_token':getToken(),
                'appCode':'zbjqxxzd',
                'currentUserCode':util.encrypt(params.userName),
                'versionName':'2.7.92',
                    'kv':{
                        'source':'MOBILE',
                        'currentUserCode':util.encrypt(params.userName),
                        'workItemId':params.idcode.workItemId,    
                        'outcome':params.outcome,    
                        'processInstId':params.idcode.processInstId,  
                        'location':params.idcode.location,  
                        'outcomeName':params.outcomeName,  
                    },
                'jsonName':'appDecision',
                'appDecision':params.flowParam    
            }
        }
    )
}
export function getxxzdTZDetail(params){
    return request (
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+
            'UsStudyFile$api$findInfoById',
            contentType: 'application/json;charset=UTF-8',
            data:{
                'access_token':getToken(),
                'appCode':'zbjqxxzd',
                'currentUserCode':util.encrypt(params.userName),
                'versionName':'2.7.92',
                'kv':{
                    'source':'MOBILE',
                    'id':params.taizhangId,
                },
            }
        }
    )
}

export function getxxzdHistory(params){
    return request (
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+
            'queryProcessHistory$api$getWorkItems',
            contentType: 'application/json;charset=UTF-8',
            data:{
                'access_token':getToken(),
                'appCode':'zbjqxxzd',
                'currentUserCode':util.encrypt(params.userName),
                'versionName':'2.7.92',
                'kv':{
                    'source':'MOBILE',
                    'processInstId':params.processInstId,  
                },
            }
        }
    )
}
export function deleteFromdata(params){
    return request (
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+
            'UsStudyMain$api$deleteDraft',
            contentType: 'application/json;charset=UTF-8',
            data:{
                'access_token':getToken(),
                'appCode':'zbjqxxzd',
                'currentUserCode':util.encrypt(params.userName),
                'versionName':'2.7.92',
                'kv':{
                    'source':'MOBILE',
                    'pmInsId':params.pmInsId,  
                    'currentUserCode':util.encrypt(params.userName),
                },
            }
        }
    )
}
export function xxzdSaveFrom(params){
    console.log('name:'+params.userName)
    var usrls='UsStudyMain$api$saveDraft';
    return request(
        {
            url:process.env.VUE_APP_URL +'/action/openapi/bps/common/transmit/'+ usrls+'?source=MOBILE',
            contentType: 'application/json;charset=UTF-8',
            data:{
                'access_token':getToken(),
                'appCode':'zbjqxxzd',
                'currentUserCode':util.encrypt(params.userName),
                'versionName':'2.7.92',
                    'kv':{
                        'source':'MOBILE',
                        'currentUserCode':util.encrypt(params.userName),
                    },
                'jsonName':'appDecision',
                'appDecision':params.flowParam    
            }
        }
    )
}